package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BuzTaskUserOption;
import com.ruoyi.system.service.IBuzTaskUserOptionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户参加活动试题可选项Controller
 * 
 * @author ruoyi
 * @date 2023-08-31
 */
@RestController
@RequestMapping("/system/buzTaskUserOption")
public class BuzTaskUserOptionController extends BaseController
{
    @Autowired
    private IBuzTaskUserOptionService buzTaskUserOptionService;

    /**
     * 查询用户参加活动试题可选项列表
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskUserOption:list')")
    @GetMapping("/list")
    public TableDataInfo list(BuzTaskUserOption buzTaskUserOption)
    {
        startPage();
        List<BuzTaskUserOption> list = buzTaskUserOptionService.selectBuzTaskUserOptionList(buzTaskUserOption);
        return getDataTable(list);
    }

    /**
     * 导出用户参加活动试题可选项列表
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskUserOption:export')")
    @Log(title = "用户参加活动试题可选项", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BuzTaskUserOption buzTaskUserOption)
    {
        List<BuzTaskUserOption> list = buzTaskUserOptionService.selectBuzTaskUserOptionList(buzTaskUserOption);
        ExcelUtil<BuzTaskUserOption> util = new ExcelUtil<BuzTaskUserOption>(BuzTaskUserOption.class);
        util.exportExcel(response, list, "用户参加活动试题可选项数据");
    }

    /**
     * 获取用户参加活动试题可选项详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskUserOption:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(buzTaskUserOptionService.selectBuzTaskUserOptionById(id));
    }

    /**
     * 新增用户参加活动试题可选项
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskUserOption:add')")
    @Log(title = "用户参加活动试题可选项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BuzTaskUserOption buzTaskUserOption)
    {
        return toAjax(buzTaskUserOptionService.insertBuzTaskUserOption(buzTaskUserOption));
    }

    /**
     * 修改用户参加活动试题可选项
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskUserOption:edit')")
    @Log(title = "用户参加活动试题可选项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BuzTaskUserOption buzTaskUserOption)
    {
        return toAjax(buzTaskUserOptionService.updateBuzTaskUserOption(buzTaskUserOption));
    }

    /**
     * 删除用户参加活动试题可选项
     */
    @PreAuthorize("@ss.hasPermi('system:buzTaskUserOption:remove')")
    @Log(title = "用户参加活动试题可选项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(buzTaskUserOptionService.deleteBuzTaskUserOptionByIds(ids));
    }
}
